public class Test {
    public static void main(String[] args) {
        int[] a = bubbleSort(new int[]{321, 2, 31, 231, 23}, 5);
        for (int i : a) {
            System.out.print(i+",");
        }
    }
    public static int[] bubbleSort(int[] a,int n){
        for (int i = 0; i < n-1; i++) {
            for (int j = 0; j < n-i-1; j++) {
                if(a[j]>a[j+1]){//相邻的比较
                    int t = a[j];
                    a[j]=a[j+1];
                    a[j+1]=t;
                }
            }
        }
        return a;
    }
}


